package com.example.android.activity;

import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;

import androidx.appcompat.app.AppCompatActivity;

import com.bumptech.glide.Glide;
import com.example.android.utils.SPUtils;

public class LauncherActivity extends AppCompatActivity {
    private final String IS_FIRST_KEY = "isFirst";

    @Override
    protected void onStart() {
        super.onStart();
        SPUtils.initSPUtils(this, "setting");
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        new Handler().postDelayed(() -> {
            boolean isFirst = SPUtils.getBoolean(IS_FIRST_KEY, true);
            if (isFirst) {
                Intent intent = new Intent(LauncherActivity.this, IntroActivity.class);
                startActivity(intent);
                SPUtils.putBoolean(IS_FIRST_KEY, false);
            } else {
                Intent intent = new Intent(LauncherActivity.this, SplashActivity.class);
                startActivity(intent);
            }
            finish();
        }, 1000);

        Glide.with(this).load("http://81.68.141.72:8888/down/6Rw5PMoyQseB").preload();
    }
}